package com.sx.junit;

import java.util.List;

import org.springframework.test.AbstractDependencyInjectionSpringContextTests;

import com.sx.article.dao.impl.ArticleDao;
import com.sx.article.entity.ArticleEntity;
import com.sx.form.dao.impl.TitleDao;
import com.sx.form.entity.TitleEntity;
import com.sx.rbac.biz.impl.MenuBiz;
import com.sx.rbac.dao.impl.SysUserDao;
import com.sx.rbac.entity.MenuEntity;
import com.sx.rbac.entity.SysUserEntity;
import com.sx.util.Secret;

public class Test extends AbstractDependencyInjectionSpringContextTests {
	private TitleDao dao;
	private SysUserDao sysuserdao;
	private MenuBiz menubiz;
	private ArticleDao adao;
	
	/**
	 * @return the adao
	 */
	public ArticleDao getAdao() {
		return adao;
	}
	/**
	 * @param adao the adao to set
	 */
	public void setAdao(ArticleDao adao) {
		this.adao = adao;
	}
	/**
	 * @return the menubiz
	 */
	public MenuBiz getMenubiz() {
		return menubiz;
	}
	/**
	 * @param menubiz the menubiz to set
	 */
	public void setMenubiz(MenuBiz menubiz) {
		this.menubiz = menubiz;
	}
	/**
	 * @return the sysuserdao
	 */
	public SysUserDao getSysuserdao() {
		return sysuserdao;
	}
	/**
	 * @param sysuserdao the sysuserdao to set
	 */
	public void setSysuserdao(SysUserDao sysuserdao) {
		this.sysuserdao = sysuserdao;
	}
	public void setDao(TitleDao dao) {
		this.dao = dao;
	}
	public Test(String name) {
		super(name);
	}
	protected String[] getConfigLocations() {
		return new String[] {
				"com/sx/config/applicationContext-common.xml",
				"com/sx/config/applicationContext-daos.xml",
				"com/sx/config/applicationContext-services.xml",
				"com/sx/config/sqlmapconfig.xml"
				};
	}
	public void testQueryArticle(){
		ArticleEntity article = new ArticleEntity();
		try {
			System.out.println(Secret.getMD5(1+""));
			/*List<ArticleEntity> list = adao.findArticleInfo(article);
			System.out.println("=========="+list.size()+"======");*/
		} catch (Exception e) {
			e.printStackTrace();
			// TODO: handle exception
		}
		
	}
	public void testAddTitle() {
//		System.out.println("----------");
		TitleEntity title = new TitleEntity();
		title.setTcontent("test33333333");
		title.setTtitle("testtitle444444444");
		try {
//			dao.addTitle(title);
			
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			fail("Not yet implemented");
		}
		//fail("Not yet implemented");
	}
	
	public void testSysusers(){
		try {
			SysUserEntity sue = new SysUserEntity();
			sue.setUserid("liqiang");
//			SysUserEntity user = sysuserdao.findSysUserOnlyOne(sue);
//			System.out.println(user.getUsername());
//			System.out.println(user.getRolesandgroups().size());
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
	}
	
	public void testMenus(){
		try {
			MenuEntity menu = new MenuEntity();
			menu.setType("first");
			menu.setIds("2,3,5,3,2,4,5,4");
//			menu.setIds("5,2,3,4");
			/*List<MenuEntity> list = menubiz.findFirstMenu(menu);
			for (int i = 0; i < list.size(); i++) {
				System.out.println(list.get(i).getMname());
			}
			System.out.println(list.size());*/
		} catch (Exception e) {
			e.printStackTrace();
			// TODO: handle exception
		}
	}
	
}
